checkbutton: Don't allow to uncheck radios by activating them
authorAlexander Mikhaylenko <alexm@gnome.org>
Thu, 20 May 2021 09:38:33 +0000 (14:38 +0500)
committerAlexander Mikhaylenko <alexm@gnome.org>
Thu, 20 May 2021 09:38:33 +0000 (14:38 +0500)
Do the same check as when clicking.

gtk/gtkcheckbutton.c

index e9a30a1ce3e67de953133431cefffca29d5e9dbf..bc4a4c5d04f2a8e16f4b28fdd217d266b4d570f0 100644 (file)
@@ -475,10 +475,14 @@ gtk_check_button_focus (GtkWidget         *widget,
 }
 
 static void
-gtk_check_button_real_activate (GtkCheckButton *check_button)
+gtk_check_button_real_activate (GtkCheckButton *self)
 {
-  gtk_check_button_set_active (check_button,
-                               !gtk_check_button_get_active (check_button));
+  GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
+
+  if (priv->active && (priv->group_prev || priv->group_next))
+    return;
+
+  gtk_check_button_set_active (self, !gtk_check_button_get_active (self));
 }
 
 static void